<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="reportTitle" value="halm机测试 - Eta效能趋势报表" scope="session"/>

<%@ include file="/common/report_head.jsp" %>
<%@ include file="/condition/sartTime_YMDH_input.html"%>
<%@ include file="/condition/endTime_YMDH_input.html"%>
<%@ include file="/condition/fab_sumo_must.html"%>
<%@ include file="/condition/attributes_sumo.html"%>
<%@ include file="/condition/line_sumo.html"%>
<%@ include file="/condition/toolg_sumo.html"%>
<%@ include file="/condition/toolType_radio.html"%>
<%@ include file="/condition/tool_sumo.html"%>
<%@ include file="/condition/spec_sumo.html"%>
<%@ include file="/condition/waferSpec_sumo.html"%>
<%@ include file="/condition/manufacturer_sumo.html"%>
<%@ include file="/condition/baseIdsumo.html"%>
<%@ include file="/condition/lotId_text.html"%>
<%--<%@ include file="/condition/effNo_sumo.html"%>--%>
<%--<%@ include file="/condition/attributes_sumo.html"%>--%>
<%--<%@ include file="/condition/gear_sumo.html"%>--%>

<%@ include file="/common/report_middle.jsp" %>
<%@ include file="/charts-grid/echarts2.html"%>
<div class="col-md-12" style="height: 420px;">
    <div id="pqGrid"></div>
</div>
<%@include file="/common/report_end.jsp" %>


<script>
    $(document).ready(function () {
        $("title").text("halm机测试 - Eta效能趋势报表");
        $("label:contains('线别:')").addClass("keyCss");

        $('#query_btn').click(function (){
            if($("#bayIdSumo").val() === null || $("#bayIdSumo").val() === '' ) { showErrorDialog("0000002", "线别为必选项"); return false; }
            initGridAndChart();
            ajax('/jn-report/report/halm_etaTrend_report.do' ,loadConditionMapData(), true, ajax_successful);

            function ajax_successful(outTrxObj) {
                if(outTrxObj.gridData.length < 1) { showMessengerDialog("数据查询为空"); return false; }

                //Chart图数据
                if ($("#charts").length > 0) {
                    var echartsData = outTrxObj.chartsData;
                    option.title.text = echartsData.title;
                    option.legend.data = [];
                    option.legend.data = echartsData.legendData;
                    option.xAxis[0].data = [];
                    option.xAxis[0].data = echartsData.xAxisData;
                    option.yAxis = [];
                    option.yAxis = [
                        {
                            type: 'value',
                            name: '柱状图',
                            splitLine:{show:false},
                            splitNumber : 12,
                            scale : true,
                            axisLabel: {formatter: '{value} %'},
                            boundaryGap: ['0%', '30%']
                        },
                        {
                            type: 'value',
                            name: '折线图',
                            splitLine:{show:false},
                            splitNumber : 12,
                            scale : true,
                            axisLabel: {formatter: '{value} %'},
                            boundaryGap: ['0%', '0%']
                        }
                    ];
                    option.series = [];
                    //柱状图
                    option.series.push({
                        name: echartsData.legendData[0],
                        type: 'bar',
                        yAxisIndex: 0,
                        data: echartsData.bar_seriesDatas[0],
                        barMinHeight : 30,
                        barMaxWidth : 29,
                        itemStyle:{
                            normal:{
                                color:function(params){
                                    var color;
                                    if(params.name.indexOf('-') > 0){
                                        color='#008080'
                                    }else{
                                        color='#B65708'
                                    }
                                    return color;
                                }
                            }
                        },
                        label: {normal: {show: true, position: 'top', distance: 5, color: 'black', fontWeight: 'bold', formatter: '{c}%'}}
                    });
                    //线别折线图
                    for (var i=0; i<echartsData.line_seriesDatas.length-1; i++) {
                        option.series.push({
                            name: echartsData.legendData[i+1],
                            type: 'line',
                            symbol: 'circle',
                            yAxisIndex: 1,
                            data: echartsData.line_seriesDatas[i]
                        });
                    }
                    //Target折线图
                    option.series.push({
                        name: echartsData.legendData[echartsData.legendData.length-1],
                        type: 'line',
                        yAxisIndex: 1,
                        itemStyle: {
                            normal: {lineStyle: { type: 'dashed', color:'#BC2003' }}
                        },
                        data: echartsData.line_seriesDatas[echartsData.line_seriesDatas.length-1]
                    });
                    option.legend.left = '7%';
                    option.backgroundColor = 'white';
                    option.grid.show = false;
                    option.legend.selectedMode = false;
                    myChart.clear();
                    myChart.setOption(option);
                }

                //grid表格数据
                if ($("#pqGrid").length > 0) {
                    var colM =[{halign:"center",align:'center', dataIndx: 'line_id', title: '线别', width: 120, editable: false, sortable: true}];
                    for (var i=0; i<outTrxObj.dynamicColumn.length; i++){
                        var date = outTrxObj.dynamicColumn[i];
                        colM.push({halign:'center', align:'center', dataIndx: date, title: date, width: 100, editable: false, sortable: true});
                    }
                    _pqUtil.f.setColModel($("#pqGrid"), colM);
                    _pqUtil.f.seTitle($("#pqGrid"), "Eta Trend数据");
                    _pqUtil.f.isShowTitle($("#pqGrid"), false);
                    _pqUtil.f.loadPqGridData($("#pqGrid"), outTrxObj.dynamicColumnJsonGridData);
                }
            }
        });

        $("#query_btn").after('<button id="export_btn" style="width: 80px;height: 23px;margin-top: 5px;margin-right: 10px;background-color: #F5F5F5;font-size: 14px;font: \'微软雅黑\';font-weight: bold;color: #428bca;border: 1px solid #191970;">导出</button>');
        $("#export_btn").click(function (){
            alert("到出源数据到Excel");
            postData(JSON.stringify(loadConditionMapData()), "halm机源数据-导出", "halm_exportExcel.do", false);
        });
    });
</script>
